package com.hz.filemanager.ui.clean;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.hz.filemanager.R;
import com.hz.filemanager.ad.utils.AnalyticsUtils;
import com.hz.filemanager.adapter.ScanAdapter;
import com.hz.filemanager.model.FileDataManager;
import com.hz.filemanager.ui.base.InterruptActivity;

public class CleanScanResultActivity extends InterruptActivity {

    private Button cleanBtn;
    private Toolbar toolbar;
    private TextView scoreTv;
    private RecyclerView listViewRv;
    private ScanAdapter scanAdapter;
    public final static String ALLSIZE = "allsize";
    private int allSize;
    private TextView dwTv;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_clean_scan_result;
    }

    @Override
    protected void initEvent() {
        AnalyticsUtils.INSTANCE.logEvent("saomiaojg_ql");

        type = getIntent().getIntExtra(TYPE, TYPE_CLEAN);
        allSize = getIntent().getIntExtra(ALLSIZE, 0);
        toolbar.setTitle(R.string.junk_clean);
        if(allSize>1000){

            scoreTv.setText(String.valueOf((float) allSize/1000));
            dwTv.setText("GB");
        }else{
            scoreTv.setText(String.valueOf(allSize));
            dwTv.setText("MB");
        }

        scanAdapter = new ScanAdapter(ScanAdapter.TYPE_RESULT);
        scanAdapter.setDatas(FileDataManager.getInstance().getScanBeanList());
        listViewRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        listViewRv.setAdapter(scanAdapter);

        cleanBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(CleanScanResultActivity.this, AnimationActivity.class);
                intent.putExtra(AnimationActivity.TYPE, AnimationActivity.TYPE_CLEAN);
                intent.putExtra(AnimationActivity.ALLSIZE, allSize);

                startActivity(intent);
                finish();
            }
        });
    }

    @Override
    protected void initView() {

        cleanBtn = findViewById(R.id.clean_result_btn);
        toolbar = findViewById(R.id.toolbar);
        scoreTv = findViewById(R.id.score_tv);
        listViewRv = findViewById(R.id.listview_rv);
        dwTv = findViewById(R.id.dw_tv);

    }
}
